<?php
/**
 * 操作日志模型
 */
namespace app\msgapi\model;

class OperateLog extends BaseModel
{
    // 相对关联，获取用户名
    public function user()
    {
        return $this->belongsTo(AdminUser::class, 'ad_uid', 'id')->bind(['username']);
    }

    // 搜索器
    public function searchAddTimeAttr($query, $value, $data)
    {
        if($value){
            list($start, $end) = explode(' ~ ',$value);
            $where[] = ['add_time','>=',$start];
            $where[] = ['add_time','<',date('Y-m-d',strtotime('+1 days',strtotime($end)))];

            $query->where($where);
        }

    }
}